<?php

use yii\helpers\Html;
use yii\grid\GridView;
use common\business\EhrHelper;
use yii\helpers\ArrayHelper;

/* @var $this yii\web\View */
/* @var $searchModel common\models\kingdee\EnrollSourceSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('app', 'Enroll Sources');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="enroll-source-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a(Yii::t('app', 'Create Enroll Source'), ['create'], ['class' => 'btn btn-success']) ?>
    </p>
    <?= GridView::widget([
        'tableOptions' => ['class' => 'table table-condensed table-bordered table-striped table-hover'],
        'pager' => [
//            'class'          => GoPager::className(),
            'nextPageLabel'  => Yii::t('app', 'Next Page'),
            'prevPageLabel'  => Yii::t('app', 'Previous Page'),
            'firstPageLabel' => Yii::t('app', 'First Page'),
            'lastPageLabel'  => Yii::t('app', 'Last Page'),
            'options' => [
                'class' => 'pagination pagination-sm m-t-none m-b-none',
            ],
        ],
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            [
                'class' => 'yii\grid\SerialColumn',
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 25px;'],
            ],

//            'FINDEX',
//            'FNAME_L1',
//            'FNAME_L2',
//            'FNAME_L3',
//            'FNUMBER',
            // 'FDESCRIPTION_L1',
            // 'FDESCRIPTION_L2',
            // 'FDESCRIPTION_L3',
            // 'FSIMPLENAME',
            // 'FCREATORID',
            // 'FCREATETIME',
            // 'FLASTUPDATEUSERID',
            // 'FLASTUPDATETIME',
            // 'FCONTROLUNITID',
            // 'FID',
            // 'FENABLE',

            [
                'label' => Yii::t('app', 'Name'),
                'attribute' => 'FNAME_L2',
                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 150px;'],
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 150px;'],
            ],
            [
                'label' => Yii::t('app', 'Alias Name'),
                'attribute' => 'FNAME_L3',
                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 150px;'],
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 150px;'],
            ],
            [
                'label' => Yii::t('app', 'Number'),
                'attribute' => 'FNUMBER',
                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 150px;'],
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 150px;'],
            ],
            [
                'attribute' => 'FCONTROLUNITID',
                'label' => Yii::t('app', 'Control Unit'),
                'value' => function ($model) {
                    return EhrHelper::getControlUnitStrById($model['FCONTROLUNITID']);
                },
                'filter' => ArrayHelper::map(\common\models\kingdee\CtrlUnit::find()->all(), 'FID', 'FNAME_L2'),
                'headerOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
                'contentOptions' => ['class' => 'vertical-middle text-center', 'style' => 'width: 100px;'],
            ],
            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>
</div>
